import jsonpath


def extract(resp: str, attr_name: str, exp: str) -> dict:
    try:
        resp.json = resp.json()
    except Exception:
        resp.json = {}
    attr = getattr(resp, attr_name)
    res = jsonpath.jsonpath(resp.json(), exp)

    return res[0]
